import http from '@/utils/http'

const BASE_URL = '/device/deviceType'

export interface DeviceTypeResp {
  id: string
  name: string
  description: string
  status: 0 | 1
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
}
export interface DeviceTypeDetailResp {
  id: string
  name: string
  description: string
  status: string
  createUser: string
  createTime: string
  updateUser: string
  updateTime: string
  createUserString: string
  updateUserString: string
  devicePipes: Array<DeviceTypePipeResp>
}

export interface DeviceTypePipeResp {
  id: string
  deviceTypeId: string
  position: string
  materialType: string
}

export interface DeviceTypeQuery {
  name: string | undefined
  status: string | undefined
  sort: Array<string>
}
export interface DeviceTypePageQuery extends DeviceTypeQuery, PageQuery {}

/** @desc 查询设备类型列表 */
export function pageDeviceType(query: DeviceTypePageQuery) {
  return http.get<PageRes<DeviceTypeResp[]>>(`${BASE_URL}`, query)
}

/** @desc 查询设备类型列表 */
export function listDeviceType(query: DeviceTypeQuery) {
  return http.get<DeviceTypeResp[]>(`${BASE_URL}/list`, query)
}

/** @desc 查询设备类型详情 */
export function getDeviceType(id: string) {
  return http.get<DeviceTypeDetailResp>(`${BASE_URL}/${id}`)
}

/** @desc 新增设备类型 */
export function addDeviceType(data: any) {
  return http.post(`${BASE_URL}`, data)
}

/** @desc 修改设备类型 */
export function updateDeviceType(data: any, id: string) {
  return http.put(`${BASE_URL}/${id}`, data)
}

/** @desc 删除设备类型 */
export function deleteDeviceType(id: string) {
  return http.del(`${BASE_URL}/${id}`)
}
